package org.bendev.ildaplayer;

import android.content.Context;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;

public class GestureHandler {
	public static interface Callback extends ScaleGestureDetector.OnScaleGestureListener{
		public void onDown( float x, float y );
		public void onUp( float x, float y );
		public void onMove( float x, float y );
	}
	
	
	final Callback callback;
	final ScaleGestureDetector scaleDetector;
	
	public GestureHandler( Context context, Callback callback ) {
		this.callback = callback;
		scaleDetector = new ScaleGestureDetector( context, callback );
	}
	
	public void onTouchEvent( MotionEvent event ){
		scaleDetector.onTouchEvent( event );
		
		switch( event.getActionMasked() ){
		case MotionEvent.ACTION_DOWN:
			callback.onDown( event.getRawX(), event.getRawY() );
			break;
		case MotionEvent.ACTION_MOVE:
			callback.onMove( event.getRawX(), event.getRawY() );
			break;
		case MotionEvent.ACTION_UP:
			callback.onUp( event.getRawX(), event.getRawY() );
			break;
/*
		case MotionEvent.ACTION_CANCEL:
			break;
		case MotionEvent.ACTION_HOVER_ENTER:
			break;
		case MotionEvent.ACTION_HOVER_EXIT:
			break;
		case MotionEvent.ACTION_OUTSIDE:
			break;
		case MotionEvent.ACTION_POINTER_DOWN:
			break;
		case MotionEvent.ACTION_POINTER_UP:
			break;
		case MotionEvent.ACTION_SCROLL:
			break;
*/
		}
	}
}
